//===============================================================================
// Microsoft patterns & practices
// Guidance Explorer Offline Client
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System;
using System.Collections.Generic;

namespace GuidanceExplorer.Model
{
    class TopSearchCriteria : Criteria
    {
        private Criteria[] _criteria;
        private int _top;
        private int _current = 0;

        public TopSearchCriteria(List<Criteria> criteria, int top)
        {
            if (criteria == null)
                throw new ArgumentNullException("criteria");
            _criteria = criteria.ToArray();
            
            _top = top;
            _current = 0;
        }

        public override void Reset()
        {
            _current = 0;
            base.Reset();
        }

        public override bool Evaluate(GuidanceItem item)
        {
            if (_current++ >= _top)
            {
                return false;
            }
            return true;
        }

        public Criteria[] Criterias
        {
            get { return _criteria; }
        }
    }
}
